import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		carList: [],
		comName:"",
		orderId:"",
		// 底部menu小红点
		TabBarBadgeNum:"67"
	},
	mutations: {
		updateCarList(state, option) {
			//处理金额溢出
			// let _remaining = option.RemainingAmount.other ? Number(option.RemainingAmount.other) : 0
   //          console.log(JSON.stringify(option))
			let idx = state.carList.findIndex(item => item.Id == option.Id)
			console.log(idx);
			if (idx > -1) state.carList[idx].num = option.num
			else state.carList.push(option)
		},
		delCarListItem(state, option) {
			state.carList.splice(option, 1)
		},
		clearCarList(state) {
			state.carList = []
		},
		setComName(state, option){
			state.comName = option
		},
		setOrderId(state,option){
			state.orderId = option
			uni.setStorageSync('orderId',option)
		},
		setTabBarBadge(state,option){
			state.TabBarBadgeNum = option
		}
	},
	actions: {

	}
})
export default store